package com.lxzh123;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DatabaseHelper extends SQLiteOpenHelper{
	public static final String TB_NAME="NotePad";
	public static final String ID="id";
	public static final String TITLE="title";
	public static final String CONTENT="content";
	public static final String LASTWRITETIME="lastwritetime";
	public static final String FILEPATH="filepath";
	
	public DatabaseHelper(Context context,String name,CursorFactory factory,int version)
	{
		super(context,name,factory,version);
	}
	
	@Override
	public void onCreate(SQLiteDatabase arg0)
	{
		arg0.execSQL("CREATE TABLE IF NOT EXISTS "+TB_NAME+"("+ID+" INTEGER PRIMARY KEY,"+TITLE+" VARCHAR,"+CONTENT+" VARCHAR,"+LASTWRITETIME+" VARCHAR)");
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion)
	{
		db.execSQL("DROP TABLE IF EXISTS "+TB_NAME);
		onCreate(db);
	}
}
